package com.ef.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.ef.constant.EGenderType;
import com.ef.constant.StatusType;

@Entity
@NamedQueries( { @NamedQuery(name = "getPassword", query = "select u from User u where u.loginName=:loginName") })
public class User implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	@Column(length = 50)
	private String name;
	
	@Column(length = 50)
	private String workcode;
	
	@Column(length = 20)
	private String loginName;

	@Column(length = 100)
	private String password;

	@Column(length = 100)
	private String email;

	@Column(length = 200)
	private String telephone;

	@Column(length = 500)
	private String address;

	@Enumerated(value = EnumType.STRING)
	private EGenderType sex;

	@Temporal(TemporalType.DATE)
	private Date birthday;

	@ManyToOne(fetch = FetchType.EAGER)
	private School school;

	@ManyToOne(fetch = FetchType.EAGER)
	private Team team;

	@ManyToOne(fetch = FetchType.EAGER)
	private Role role;
	
	@ManyToOne(fetch = FetchType.EAGER)
	private Department department;
	
	@Column(length =50)
    private String telCode;
    
    @Enumerated(value = EnumType.STRING)
	private StatusType status = StatusType.VALID;

	public StatusType getStatus() {
		return status;
	}

	public void setStatus(StatusType status) {
		this.status = status;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public EGenderType getSex() {
		return sex;
	}

	public void setSex(EGenderType sex) {
		this.sex = sex;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public School getSchool() {
		return school;
	}

	public void setSchool(School school) {
		this.school = school;
	}

	public Team getTeam() {
		return team;
	}

	public void setTeam(Team team) {
		this.team = team;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public String getWorkcode() {
		return workcode;
	}

	public void setWorkcode(String workcode) {
		this.workcode = workcode;
	}

	public String getTelCode() {
		return telCode;
	}

	public void setTelCode(String telCode) {
		this.telCode = telCode;
	}
}
